Library

library(quantmod)
library(tseries)
library(FinTS)
library(fracdiff)
library(lmtest)
library(forecast)
library(ggplot2)
library(reshape2)
library(scales)
library(rugarch)
library(PerformanceAnalytics)
library(urca)
library(zoo)
library(xts)

Data (Stock - Reliance & Index - Nifty 50)

getSymbols(c("^NSEI", "RELIANCE.NS"), src = "yahoo", from = "2021-10-01", to = "2025-01-01", periodicity = "d")
## [1] "NSEI"        "RELIANCE.NS"
merged_prices <- merge(Cl(NSEI), Cl(RELIANCE.NS))  
colnames(merged_prices) <- c("Nifty50", "Reliance")

#Calculate Daily Log Returns (in percent)
log_returns <- na.omit(100 * diff(log(merged_prices)))
stock <- log_returns$Reliance
index <- log_returns$Nifty50

Plots (log return, Acf & Pacf)

par(mfrow = c(2, 1))
plot(stock, main = "Reliance Log Returns", col = "black", ylab = "Log Return", xlab = "Date", type = "l")
plot(index, main = "Nifty 50 Log Returns", col = "skyblue", ylab = "Log Return", xlab = "Date", type = "l")

par(mfrow = c(2, 2))
asset_name = "Reliance"
Acf(stock, main = paste("Reliance - ", "ACF"))
Pacf(stock, main = paste("Reliance - ", "PACF"))

asset_name = "Nifty 50"
Acf(index, main = paste("Nifty 50 - ", "ACF"))
Pacf(index, main = paste("Nifty 50 - ", "PACF"))

Test (Normality,Unit Root Test, ARCH Effect Test, Long Memory Test, signbias_test)

Normality Test

shapiro.test(coredata(stock)) 
## 
##  Shapiro-Wilk normality test
## 
## data:  coredata(stock)
## W = 0.96655, p-value = 1.414e-12
# Data is not normally distributed 

shapiro.test(coredata(index))
## 
##  Shapiro-Wilk normality test
## 
## data:  coredata(index)
## W = 0.95772, p-value = 1.996e-14
# Data is not normally distributed

cat("Both Stock and Index are ** Non-Normal Distributed **")
## Both Stock and Index are ** Non-Normal Distributed **

Unit Root ADF

adf.test(stock) 
## Warning in adf.test(stock): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  stock
## Dickey-Fuller = -9.4392, Lag order = 9, p-value = 0.01
## alternative hypothesis: stationary
# staionary data
adf.test(index) 
## Warning in adf.test(index): p-value smaller than printed p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  index
## Dickey-Fuller = -9.5316, Lag order = 9, p-value = 0.01
## alternative hypothesis: stationary
# staionary data

cat("Both Stock and Index are ** Stationary **")
## Both Stock and Index are ** Stationary **

Long memory test

fracdiff(stock)
## 
## Call:
##   fracdiff(x = stock) 
## 
## Coefficients:
##            d 
## 4.583013e-05 
## sigma[eps] = 1.456256 
## a list with components:
##  [1] "log.likelihood"  "n"               "msg"             "d"              
##  [5] "ar"              "ma"              "covariance.dpq"  "fnormMin"       
##  [9] "sigma"           "stderror.dpq"    "correlation.dpq" "h"              
## [13] "d.tol"           "M"               "hessian.dpq"     "length.w"       
## [17] "residuals"       "fitted"          "call"
# d = 4.58e-05 (≈ 0) => does not exhibit long memory

fracdiff(index)
## 
## Call:
##   fracdiff(x = index) 
## 
## Coefficients:
##            d 
## 4.583013e-05 
## sigma[eps] = 0.8951393 
## a list with components:
##  [1] "log.likelihood"  "n"               "msg"             "d"              
##  [5] "ar"              "ma"              "covariance.dpq"  "fnormMin"       
##  [9] "sigma"           "stderror.dpq"    "correlation.dpq" "h"              
## [13] "d.tol"           "M"               "hessian.dpq"     "length.w"       
## [17] "residuals"       "fitted"          "call"
# d = 4.583013e-05 (≈ 0) => does not exhibit long memory

cat("Both Stock and Index have ** Short memory **")
## Both Stock and Index have ** Short memory **

ARCH test

ArchTest(stock, lags = 10)
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  stock
## Chi-squared = 22.363, df = 10, p-value = 0.01336
#  Arch-Effect is Present  

ArchTest(index, lags = 10)
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  index
## Chi-squared = 98.911, df = 10, p-value < 2.2e-16
# Arch-Effect is Present  

cat("Both Stock and Index have ** significant ARCH effects **")
## Both Stock and Index have ** significant ARCH effects **

Sign Bias test

garch_spec <- ugarchspec(
  variance.model = list(model = "sGARCH", garchOrder = c(1,1)),
  mean.model     = list(armaOrder = c(1,1), include.mean = TRUE),
  distribution.model = "norm"
)

garch_fit_stock <- ugarchfit(spec = garch_spec, data = stock)
garch_fit_index <- ugarchfit(spec = garch_spec, data = index)
## Warning in arima(data, order = c(modelinc[2], 0, modelinc[3]), include.mean =
## modelinc[1], : possible convergence problem: optim gave code = 1
signbias(garch_fit_stock)
##                     t-value      prob sig
## Sign Bias          1.622755 0.1050377    
## Negative Sign Bias 1.533319 0.1255946    
## Positive Sign Bias 1.089141 0.2764215    
## Joint Effect       3.685683 0.2974660
signbias(garch_fit_index)
##                      t-value      prob sig
## Sign Bias          1.5389862 0.1242051    
## Negative Sign Bias 0.5048758 0.6137858    
## Positive Sign Bias 0.8646990 0.3874645    
## Joint Effect       4.6765573 0.1970722
cat("Both Stock and Index have ** No significant asymmetry  **")
## Both Stock and Index have ** No significant asymmetry  **

ARMA Model - stock (Reliance)

# ARMA (0,0)
arma00 <- arima(stock, order = c(0,0,0)) # log likelihood = -1437.64,  aic = 2879.28
summary(arma00)
## 
## Call:
## arima(x = stock, order = c(0, 0, 0))
## 
## Coefficients:
##       intercept
##          0.0053
## s.e.     0.0515
## 
## sigma^2 estimated as 2.121:  log likelihood = -1437.64,  aic = 2879.28
## 
## Training set error measures:
##                        ME     RMSE      MAE      MPE     MAPE     MASE
## Training set -7.48465e-17 1.456253 1.061418 100.1662 100.6747 0.688961
##                    ACF1
## Training set -0.0161454
# ARMA(1,0)
arma10 <- arima(stock, order = c(1,0,0)) # log likelihood = -1437.53,  aic = 2881.07
summary(arma10)
## 
## Call:
## arima(x = stock, order = c(1, 0, 0))
## 
## Coefficients:
##           ar1  intercept
##       -0.0161     0.0053
## s.e.   0.0353     0.0506
## 
## sigma^2 estimated as 2.12:  log likelihood = -1437.53,  aic = 2881.07
## 
## Training set error measures:
##                        ME     RMSE      MAE      MPE     MAPE      MASE
## Training set 2.543475e-05 1.456062 1.061917 102.6262 102.9787 0.6892852
##                      ACF1
## Training set 0.0001990777
# ARMA(0,1)
arma01 <- arima(stock, order = c(0,0,1)) # log likelihood = -1437.54,  aic = 2881.07
summary(arma01)
## 
## Call:
## arima(x = stock, order = c(0, 0, 1))
## 
## Coefficients:
##           ma1  intercept
##       -0.0158     0.0053
## s.e.   0.0350     0.0506
## 
## sigma^2 estimated as 2.12:  log likelihood = -1437.54,  aic = 2881.07
## 
## Training set error measures:
##                        ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 6.919107e-06 1.456067 1.06191 102.5167 102.8533 0.6892801
##                       ACF1
## Training set -0.0001635539
# ARMA(1,1)
arma11 <- arima(stock, order = c(1,0,1)) # log likelihood = -1436.76,  aic = 2881.53
summary(arma11)
## 
## Call:
## arima(x = stock, order = c(1, 0, 1))
## 
## Coefficients:
##          ar1      ma1  intercept
##       0.8829  -0.9050     0.0052
## s.e.  0.1504   0.1364     0.0419
## 
## sigma^2 estimated as 2.116:  log likelihood = -1436.76,  aic = 2881.53
## 
## Training set error measures:
##                        ME     RMSE     MAE      MPE     MAPE      MASE
## Training set 0.0008050277 1.454651 1.06254 112.3929 118.5012 0.6896893
##                     ACF1
## Training set 0.003824042
# ARMA(2,0)
arma20 <- arima(stock, order = c(2,0,0)) #  log likelihood = -1437.47,  aic = 2882.94
summary(arma20)
## 
## Call:
## arima(x = stock, order = c(2, 0, 0))
## 
## Coefficients:
##           ar1     ar2  intercept
##       -0.0159  0.0126     0.0053
## s.e.   0.0353  0.0354     0.0513
## 
## sigma^2 estimated as 2.12:  log likelihood = -1437.47,  aic = 2882.94
## 
## Training set error measures:
##                         ME     RMSE      MAE    MPE     MAPE      MASE
## Training set -3.417605e-05 1.455946 1.061706 105.67 106.8302 0.6891476
##                     ACF1
## Training set 0.001085547
# ARMA(0,2)
arma02 <- arima(stock, order = c(0,0,2)) #  log likelihood = -1437.5,  aic = 2882.99
summary(arma02)
## 
## Call:
## arima(x = stock, order = c(0, 0, 2))
## 
## Coefficients:
##           ma1     ma2  intercept
##       -0.0141  0.0103     0.0053
## s.e.   0.0358  0.0357     0.0512
## 
## sigma^2 estimated as 2.12:  log likelihood = -1437.5,  aic = 2882.99
## 
## Training set error measures:
##                         ME     RMSE      MAE      MPE     MAPE      MASE
## Training set -1.621463e-05 1.455991 1.061668 104.6583 105.3018 0.6891234
##                       ACF1
## Training set -0.0009257076
# ARMA(2,2)
arma22 <- arima(stock, order = c(2,0,2)) # log likelihood = -1432.85,  aic = 2877.71
summary(arma22)
## 
## Call:
## arima(x = stock, order = c(2, 0, 2))
## 
## Coefficients:
##           ar1      ar2     ma1     ma2  intercept
##       -0.9874  -0.9656  1.0103  0.9997     0.0059
## s.e.   0.0145   0.0107  0.0116  0.0195     0.0520
## 
## sigma^2 estimated as 2.085:  log likelihood = -1432.85,  aic = 2877.71
## 
## Training set error measures:
##                         ME     RMSE      MAE      MPE     MAPE    MASE
## Training set -0.0005299047 1.443957 1.057919 96.60171 151.0894 0.68669
##                     ACF1
## Training set -0.03007662
#ARMA(3,0)
arma30 <- arima(stock, order = c(3,0,0)) # log likelihood = -1434.36,  aic = 2878.72
summary(arma30)
## 
## Call:
## arima(x = stock, order = c(3, 0, 0))
## 
## Coefficients:
##           ar1     ar2      ar3  intercept
##       -0.0147  0.0113  -0.0881     0.0052
## s.e.   0.0352  0.0352   0.0352     0.0470
## 
## sigma^2 estimated as 2.103:  log likelihood = -1434.36,  aic = 2878.72
## 
## Training set error measures:
##                        ME     RMSE      MAE      MPE     MAPE      MASE
## Training set 0.0001246886 1.450282 1.063358 148.4398 163.3296 0.6902199
##                      ACF1
## Training set 0.0001496099
#ARMA(0,3)
arma03 <- arima(stock, order = c(0,0,3)) # log likelihood = -1434.68,  aic = 2879.35
summary(arma03)
## 
## Call:
## arima(x = stock, order = c(0, 0, 3))
## 
## Coefficients:
##           ma1     ma2      ma3  intercept
##       -0.0148  0.0089  -0.0801     0.0052
## s.e.   0.0353  0.0353   0.0337     0.0469
## 
## sigma^2 estimated as 2.105:  log likelihood = -1434.68,  aic = 2879.35
## 
## Training set error measures:
##                        ME     RMSE      MAE      MPE     MAPE     MASE
## Training set 9.748187e-05 1.450859 1.063395 142.8417 154.8663 0.690244
##                       ACF1
## Training set -0.0002213725
# ARMA(3,3)
arma33 <- arima(stock, order = c(3,0,3)) # log likelihood = -1431.77,  aic = 2879.54
summary(arma33)
## 
## Call:
## arima(x = stock, order = c(3, 0, 3))
## 
## Coefficients:
## Warning in sqrt(diag(x$var.coef)): NaNs produced
##           ar1      ar2    ar3     ma1     ma2     ma3  intercept
##       -0.1242  -0.1148  0.831  0.1219  0.1026  -0.888     0.0050
## s.e.      NaN      NaN    NaN     NaN     NaN   0.046     0.0421
## 
## sigma^2 estimated as 2.079:  log likelihood = -1431.77,  aic = 2879.54
## 
## Training set error measures:
##                       ME     RMSE      MAE      MPE    MAPE      MASE
## Training set 0.001017894 1.441909 1.058898 109.6531 158.152 0.6873255
##                      ACF1
## Training set -0.007072237

Best Model - Stock (reliance)

cat("Best Model is ---->  ** arma(2,2) ** ")
## Best Model is ---->  ** arma(2,2) **
# Among all the model, 
#(2,2) has lowest AIC with aic(2,2) = 2877.71,
# Also, coefficient ar1,ar2 and ma1, ma2 is statstically significant

arma_residuals <- residuals(arma22)

#Heteroskedasticity
ArchTest(arma_residuals, lags = 10)
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  arma_residuals
## Chi-squared = 21.061, df = 10, p-value = 0.02067
# Presence of ARCH effects => consider GARCH models

# White noise
Box.test(arma_residuals, lag = 10, type = "Ljung-Box") # p-value = 0.3489
## 
##  Box-Ljung test
## 
## data:  arma_residuals
## X-squared = 11.111, df = 10, p-value = 0.3489
# Residuals are not autocorrelated and behave like white noise

# Normality test
shapiro.test(arma_residuals) 
## 
##  Shapiro-Wilk normality test
## 
## data:  arma_residuals
## W = 0.96907, p-value = 5.447e-12
# Residuals are not normally distributed (presence of tails, skewness, or kurtosis)

# ACF
asset_name = "(Residuals - Reliance) - "
acf(arma_residuals, main = paste(asset_name, "ACF"))

ARMA Model - Index (Nifty 500)

# ARMA (0,0)
Arma00 <- arima(index, order = c(0,0,0)) # log likelihood = -1047.84,  aic = 2099.67
summary(Arma00)
## 
## Call:
## arima(x = index, order = c(0, 0, 0))
## 
## Coefficients:
##       intercept
##          0.0373
## s.e.     0.0316
## 
## sigma^2 estimated as 0.8013:  log likelihood = -1047.84,  aic = 2099.67
## 
## Training set error measures:
##                        ME      RMSE       MAE  MPE MAPE      MASE        ACF1
## Training set 6.531232e-15 0.8951382 0.6526778 -Inf  Inf 0.7330358 -0.01728411
# ARMA(1,0)
Arma10 <- arima(index, order = c(1,0,0)) # log likelihood = -1047.72,  aic = 2101.44
summary(Arma10)
## 
## Call:
## arima(x = index, order = c(1, 0, 0))
## 
## Coefficients:
##           ar1  intercept
##       -0.0173     0.0373
## s.e.   0.0353     0.0311
## 
## sigma^2 estimated as 0.801:  log likelihood = -1047.72,  aic = 2101.44
## 
## Training set error measures:
##                        ME      RMSE       MAE  MPE MAPE      MASE         ACF1
## Training set 1.853828e-05 0.8950043 0.6533607 -Inf  Inf 0.7338027 0.0001328109
# ARMA(0,1)
Arma01 <- arima(index, order = c(0,0,1)) # log likelihood = -1047.72,  aic = 2101.44
summary(Arma01)
## 
## Call:
## arima(x = index, order = c(0, 0, 1))
## 
## Coefficients:
##           ma1  intercept
##       -0.0170     0.0373
## s.e.   0.0351     0.0311
## 
## sigma^2 estimated as 0.801:  log likelihood = -1047.72,  aic = 2101.44
## 
## Training set error measures:
##                        ME      RMSE      MAE  MPE MAPE      MASE          ACF1
## Training set 8.678214e-06 0.8950063 0.653351 -Inf  Inf 0.7337919 -0.0001291844
# ARMA(1,1)
Arma11 <- arima(index, order = c(1,0,1)) #  log likelihood = -1047.25,  aic = 2102.51
## Warning in arima(index, order = c(1, 0, 1)): possible convergence problem:
## optim gave code = 1
summary(Arma11)
## 
## Call:
## arima(x = index, order = c(1, 0, 1))
## 
## Coefficients:
##           ar1     ma1  intercept
##       -0.7617  0.7367     0.0360
## s.e.   0.2842  0.2914     0.0312
## 
## sigma^2 estimated as 0.8001:  log likelihood = -1047.25,  aic = 2102.51
## 
## Training set error measures:
##                       ME      RMSE       MAE  MPE MAPE      MASE        ACF1
## Training set 0.001317732 0.8944832 0.6530551 -Inf  Inf 0.7334595 0.009083419
# ARMA(2,0)
Arma20 <- arima(index, order = c(2,0,0)) # log likelihood = -1047.69,  aic = 2103.39
summary(Arma20)
## 
## Call:
## arima(x = index, order = c(2, 0, 0))
## 
## Coefficients:
##           ar1     ar2  intercept
##       -0.0171  0.0078     0.0373
## s.e.   0.0353  0.0353     0.0313
## 
## sigma^2 estimated as 0.801:  log likelihood = -1047.69,  aic = 2103.39
## 
## Training set error measures:
##                        ME      RMSE       MAE  MPE MAPE      MASE         ACF1
## Training set 4.068677e-07 0.8949774 0.6533283 -Inf  Inf 0.7337664 0.0001164638
# ARMA(0,2)
Arma02 <- arima(index, order = c(0,0,2)) # log likelihood = -1047.7,  aic = 2103.4
summary(Arma02)
## 
## Call:
## arima(x = index, order = c(0, 0, 2))
## 
## Coefficients:
##           ma1     ma2  intercept
##       -0.0169  0.0069     0.0373
## s.e.   0.0353  0.0339     0.0313
## 
## sigma^2 estimated as 0.801:  log likelihood = -1047.7,  aic = 2103.4
## 
## Training set error measures:
##                         ME      RMSE       MAE  MPE MAPE     MASE          ACF1
## Training set -2.352259e-06 0.8949829 0.6533262 -Inf  Inf 0.733764 -0.0001081153
# ARMA(2,2)
Arma22 <- arima(index, order = c(2,0,2)) # log likelihood = -1046.07,  aic = 2104.14
## Warning in arima(index, order = c(2, 0, 2)): possible convergence problem:
## optim gave code = 1
summary(Arma22)
## 
## Call:
## arima(x = index, order = c(2, 0, 2))
## 
## Coefficients:
## Warning in sqrt(diag(x$var.coef)): NaNs produced
##           ar1      ar2     ma1     ma2  intercept
##       -1.7171  -0.8876  1.7185  0.9016     0.0331
## s.e.   0.0337      NaN     NaN     NaN     0.0317
## 
## sigma^2 estimated as 0.7977:  log likelihood = -1046.07,  aic = 2104.14
## 
## Training set error measures:
##                       ME      RMSE      MAE  MPE MAPE      MASE        ACF1
## Training set 0.004262089 0.8931376 0.652483 -Inf  Inf 0.7328169 -0.01438681

Best ARMA Model - Index (Nifty 50)

cat("Best Model is ---->  ** Arma(0,0) ** ")
## Best Model is ---->  ** Arma(0,0) **
# arma(0,0) has the lowest AIC = 2099.67

Arma_residuals <- residuals(Arma00)

#Heteroskedasticity
ArchTest(Arma_residuals, lags = 10)
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  Arma_residuals
## Chi-squared = 94.778, df = 10, p-value = 6.015e-16
# Presence of ARCH effects => consider GARCH models

# White noise
Box.test(Arma_residuals, lag = 10, type = "Ljung-Box") # p-value = 0.859
## 
##  Box-Ljung test
## 
## data:  Arma_residuals
## X-squared = 4.0099, df = 10, p-value = 0.9469
# Residuals are not autocorrelated and behave like white noise

# Normality test
shapiro.test(Arma_residuals) 
## 
##  Shapiro-Wilk normality test
## 
## data:  Arma_residuals
## W = 0.95772, p-value = 1.996e-14
# Residuals are not normally distributed (presence of tails, skewness, or kurtosis)

# ACF
asset_name = "(Residuals - Nifty 50) - "
acf(Arma_residuals, main = paste(asset_name, "ACF"))

Garch Model - Stock (Reliance) With arma(2,2)

# Mean model spec (ARMA(2,2) with mean)
mean_ <- list(armaOrder = c(2,2), include.mean = TRUE)

# GARCH(1,1)
spec_garch <- ugarchspec(
  variance.model = list(model = "sGARCH", garchOrder = c(1,1)),
  mean.model = mean_,
  distribution.model = "std"
)
fit_garch <- ugarchfit(spec_garch, data = stock)
show(fit_garch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.004495    0.044226    0.10163 0.919052
## ar1    -0.253036    0.003378  -74.90400 0.000000
## ar2    -0.985059    0.005184 -190.01784 0.000000
## ma1     0.262902    0.000974  269.89101 0.000000
## ma2     1.003423    0.000166 6054.73812 0.000000
## omega   0.023862    0.012568    1.89867 0.057608
## alpha1  0.024658    0.008056    3.06081 0.002207
## beta1   0.963140    0.009927   97.02372 0.000000
## shape   5.177255    0.880597    5.87925 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.004495    0.042701    0.10526 0.916171
## ar1    -0.253036    0.003616  -69.97141 0.000000
## ar2    -0.985059    0.004646 -212.04243 0.000000
## ma1     0.262902    0.000881  298.26753 0.000000
## ma2     1.003423    0.000143 7032.97975 0.000000
## omega   0.023862    0.010891    2.19105 0.028448
## alpha1  0.024658    0.006793    3.62992 0.000284
## beta1   0.963140    0.006332  152.11617 0.000000
## shape   5.177255    0.900127    5.75170 0.000000
## 
## LogLikelihood : -1378.746 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       3.4650
## Bayes        3.5177
## Shibata      3.4648
## Hannan-Quinn 3.4853
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                      0.2853 0.59324
## Lag[2*(p+q)+(p+q)-1][11]    7.3386 0.01759
## Lag[4*(p+q)+(p+q)-1][19]    9.3805 0.57354
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      10.21 0.001395
## Lag[2*(p+q)+(p+q)-1][5]     12.58 0.001959
## Lag[4*(p+q)+(p+q)-1][9]     13.68 0.007392
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     3.483 0.500 2.000  0.0620
## ARCH Lag[5]     4.133 1.440 1.667  0.1623
## ARCH Lag[7]     4.292 2.315 1.543  0.3064
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.6705
## Individual Statistics:              
## mu     0.07643
## ar1    0.23622
## ar2    0.07354
## ma1    0.04569
## ma2    0.16970
## omega  0.20743
## alpha1 0.50854
## beta1  0.36649
## shape  0.49336
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.1 2.32 2.82
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias           1.1447 0.25268    
## Negative Sign Bias  0.6743 0.50033    
## Positive Sign Bias  1.9046 0.05719   *
## Joint Effect        4.1443 0.24630    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     23.04       0.2354
## 2    30     25.93       0.6293
## 3    40     34.71       0.6661
## 4    50     49.50       0.4532
## 
## 
## Elapsed time : 0.1988499
# GJR-GARCH(1,1)
spec_gjr <- ugarchspec(
  variance.model = list(model = "gjrGARCH", garchOrder = c(1,1)),
  mean.model = mean_,
  distribution.model = "std"
)
fit_gjr <- ugarchfit(spec_gjr, data = stock)
show(fit_gjr)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.003460    0.044633   0.077513  0.93822
## ar1    -1.594729    0.029236 -54.547471  0.00000
## ar2    -0.703995    0.041682 -16.889617  0.00000
## ma1     1.603377    0.025161  63.725599  0.00000
## ma2     0.730126    0.034067  21.432137  0.00000
## omega   0.020210    0.024915   0.811166  0.41727
## alpha1  0.019816    0.013148   1.507124  0.13178
## beta1   0.967193    0.023854  40.545844  0.00000
## gamma1  0.005345    0.019440   0.274933  0.78337
## shape   5.204163    0.917178   5.674104  0.00000
## 
## Robust Standard Errors:
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.003460    0.043470   0.079587 0.936566
## ar1    -1.594729    0.042492 -37.530261 0.000000
## ar2    -0.703995    0.022920 -30.714898 0.000000
## ma1     1.603377    0.028860  55.556460 0.000000
## ma2     0.730126    0.004670 156.339142 0.000000
## omega   0.020210    0.038610   0.523452 0.600660
## alpha1  0.019816    0.017613   1.125111 0.260542
## beta1   0.967193    0.036006  26.862314 0.000000
## gamma1  0.005345    0.021785   0.245342 0.806191
## shape   5.204163    1.043086   4.989199 0.000001
## 
## LogLikelihood : -1382.629 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       3.4772
## Bayes        3.5357
## Shibata      3.4769
## Hannan-Quinn 3.4997
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                      0.2121  0.6452
## Lag[2*(p+q)+(p+q)-1][11]    3.6668  1.0000
## Lag[4*(p+q)+(p+q)-1][19]    4.8133  0.9960
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      12.07 0.0005129
## Lag[2*(p+q)+(p+q)-1][5]     14.34 0.0006663
## Lag[4*(p+q)+(p+q)-1][9]     15.28 0.0030558
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     3.359 0.500 2.000 0.06684
## ARCH Lag[5]     3.832 1.440 1.667 0.18968
## ARCH Lag[7]     3.903 2.315 1.543 0.36080
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.5717
## Individual Statistics:              
## mu     0.07847
## ar1    0.08516
## ar2    0.03335
## ma1    0.11008
## ma2    0.05237
## omega  0.19667
## alpha1 0.47640
## beta1  0.34799
## gamma1 0.51915
## shape  0.49625
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value     prob sig
## Sign Bias            1.920 0.055213   *
## Negative Sign Bias   1.078 0.281487    
## Positive Sign Bias   2.599 0.009535 ***
## Joint Effect         7.916 0.047770  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     17.65       0.5458
## 2    30     24.21       0.7187
## 3    40     40.70       0.3956
## 4    50     35.64       0.9232
## 
## 
## Elapsed time : 0.2978539
# EGARCH(1,1)
spec_egarch <- ugarchspec(
  variance.model = list(model = "eGARCH", garchOrder = c(1,1)),
  mean.model = mean_,
  distribution.model = "std"
)
fit_egarch <- ugarchfit(spec_egarch, data = stock)
show(fit_egarch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : eGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error     t value Pr(>|t|)
## mu      0.006099    0.043731  1.3946e-01  0.88909
## ar1    -1.120038    0.000067 -1.6727e+04  0.00000
## ar2    -1.032701    0.000066 -1.5647e+04  0.00000
## ma1     1.120038    0.000071  1.5758e+04  0.00000
## ma2     1.032701    0.000029  3.5270e+04  0.00000
## omega   0.008260    0.002723  3.0332e+00  0.00242
## alpha1 -0.011337    0.017936 -6.3210e-01  0.52732
## beta1   0.987248    0.000015  6.6383e+04  0.00000
## gamma1  0.071843    0.006673  1.0767e+01  0.00000
## shape   5.263153    0.930160  5.6583e+00  0.00000
## 
## Robust Standard Errors:
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.006099    0.168333   0.036230  0.97110
## ar1    -1.120038    0.017618 -63.575222  0.00000
## ar2    -1.032701    0.011297 -91.411657  0.00000
## ma1     1.120038    0.017721  63.203603  0.00000
## ma2     1.032701    0.024142  42.776000  0.00000
## omega   0.008260    0.332964   0.024808  0.98021
## alpha1 -0.011337    0.473519  -0.023942  0.98090
## beta1   0.987248    0.006636 148.782564  0.00000
## gamma1  0.071843    1.044588   0.068777  0.94517
## shape   5.263153  159.262109   0.033047  0.97364
## 
## LogLikelihood : -1382.217 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       3.4762
## Bayes        3.5347
## Shibata      3.4759
## Hannan-Quinn 3.4987
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                     0.07184 0.7886774
## Lag[2*(p+q)+(p+q)-1][11]   8.30877 0.0002726
## Lag[4*(p+q)+(p+q)-1][19]  10.44214 0.3966313
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      11.02 0.000901
## Lag[2*(p+q)+(p+q)-1][5]     13.34 0.001236
## Lag[4*(p+q)+(p+q)-1][9]     14.37 0.005059
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     3.626 0.500 2.000 0.05688
## ARCH Lag[5]     3.950 1.440 1.667 0.17847
## ARCH Lag[7]     4.092 2.315 1.543 0.33354
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  14.6898
## Individual Statistics:              
## mu     0.08568
## ar1    0.29267
## ar2    0.18840
## ma1    0.29327
## ma2    0.21050
## omega  0.28051
## alpha1 0.22711
## beta1  0.48314
## gamma1 0.11503
## shape  0.41463
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias            1.821 0.06898   *
## Negative Sign Bias   1.213 0.22557    
## Positive Sign Bias   2.551 0.01092  **
## Joint Effect         8.000 0.04602  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     13.71       0.8005
## 2    30     20.54       0.8755
## 3    40     27.41       0.9181
## 4    50     47.25       0.5442
## 
## 
## Elapsed time : 0.569818
# IGARCH(1,1)
spec_igarch <- ugarchspec(
  variance.model = list(model = "iGARCH", garchOrder = c(1,1)),
  mean.model = mean_,
  distribution.model = "std"
)
fit_igarch <- ugarchfit(spec_igarch, data = stock)
show(fit_igarch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : iGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error   t value Pr(>|t|)
## mu      0.008753    0.044402   0.19714 0.843717
## ar1    -1.596360    0.022595 -70.65127 0.000000
## ar2    -0.701083    0.039875 -17.58200 0.000000
## ma1     1.602299    0.020942  76.51027 0.000000
## ma2     0.724197    0.032233  22.46722 0.000000
## omega   0.001409    0.003792   0.37157 0.710214
## alpha1  0.018023    0.008387   2.14890 0.031642
## beta1   0.981977          NA        NA       NA
## shape   4.882789    0.793912   6.15029 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error   t value Pr(>|t|)
## mu      0.008753    0.045533   0.19224  0.84755
## ar1    -1.596360    0.039262 -40.65885  0.00000
## ar2    -0.701083    0.025902 -27.06695  0.00000
## ma1     1.602299    0.025164  63.67345  0.00000
## ma2     0.724197    0.004700 154.09582  0.00000
## omega   0.001409    0.004971   0.28340  0.77687
## alpha1  0.018023    0.011260   1.60069  0.10945
## beta1   0.981977          NA        NA       NA
## shape   4.882789    0.893594   5.46421  0.00000
## 
## LogLikelihood : -1383.796 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       3.4751
## Bayes        3.5219
## Shibata      3.4749
## Hannan-Quinn 3.4931
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                       0.302  0.5826
## Lag[2*(p+q)+(p+q)-1][11]     3.716  1.0000
## Lag[4*(p+q)+(p+q)-1][19]     4.880  0.9954
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      15.51 8.204e-05
## Lag[2*(p+q)+(p+q)-1][5]     18.66 4.516e-05
## Lag[4*(p+q)+(p+q)-1][9]     19.80 2.264e-04
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     5.052 0.500 2.000 0.02459
## ARCH Lag[5]     5.248 1.440 1.667 0.09003
## ARCH Lag[7]     5.277 2.315 1.543 0.19795
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.2827
## Individual Statistics:              
## mu     0.08462
## ar1    0.08036
## ar2    0.02898
## ma1    0.10792
## ma2    0.04696
## omega  0.06879
## alpha1 0.19252
## shape  0.28142
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.89 2.11 2.59
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value     prob sig
## Sign Bias            2.043 0.041367  **
## Negative Sign Bias   1.129 0.259376    
## Positive Sign Bias   2.823 0.004872 ***
## Joint Effect         9.245 0.026203  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     13.26       0.8251
## 2    30     23.98       0.7299
## 3    40     29.41       0.8671
## 4    50     37.51       0.8843
## 
## 
## Elapsed time : 0.09199214
# APARCH(1,1)
spec_aparch <- ugarchspec(
  variance.model = list(model = "apARCH", garchOrder = c(1,1)),
  mean.model = mean_,
  distribution.model = "std"
)
fit_aparch <- ugarchfit(spec_aparch, data = stock)
show(fit_aparch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : apARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error     t value Pr(>|t|)
## mu      0.003011    0.043884  6.8607e-02  0.94530
## ar1    -1.812423    0.003523 -5.1450e+02  0.00000
## ar2    -0.982901    0.002207 -4.4533e+02  0.00000
## ma1     1.824259    0.003624  5.0341e+02  0.00000
## ma2     0.996060    0.000125  7.9587e+03  0.00000
## omega   0.006784    0.005528  1.2272e+00  0.21975
## alpha1  0.000171    0.000186  9.2023e-01  0.35745
## beta1   0.991649    0.000953  1.0411e+03  0.00000
## gamma1 -0.999999    0.000745 -1.3427e+03  0.00000
## delta   3.500000    0.403200  8.6806e+00  0.00000
## shape   5.167394    1.013852  5.0968e+00  0.00000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.003011         NaN      NaN      NaN
## ar1    -1.812423         NaN      NaN      NaN
## ar2    -0.982901         NaN      NaN      NaN
## ma1     1.824259         NaN      NaN      NaN
## ma2     0.996060         NaN      NaN      NaN
## omega   0.006784         NaN      NaN      NaN
## alpha1  0.000171         NaN      NaN      NaN
## beta1   0.991649         NaN      NaN      NaN
## gamma1 -0.999999         NaN      NaN      NaN
## delta   3.500000         NaN      NaN      NaN
## shape   5.167394         NaN      NaN      NaN
## 
## LogLikelihood : -1377.869 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       3.4678
## Bayes        3.5322
## Shibata      3.4675
## Hannan-Quinn 3.4926
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                      0.5644 0.45248
## Lag[2*(p+q)+(p+q)-1][11]    6.9034 0.07187
## Lag[4*(p+q)+(p+q)-1][19]    8.4309 0.73087
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      13.86 0.0001968
## Lag[2*(p+q)+(p+q)-1][5]     16.52 0.0001732
## Lag[4*(p+q)+(p+q)-1][9]     17.55 0.0008437
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     4.257 0.500 2.000 0.03908
## ARCH Lag[5]     4.489 1.440 1.667 0.13467
## ARCH Lag[7]     4.575 2.315 1.543 0.27110
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  NaN
## Individual Statistics:              
## mu     0.12019
## ar1    0.03289
## ar2    0.04268
## ma1    0.01824
## ma2    0.02405
## omega  0.15889
## alpha1 0.11731
## beta1  0.14395
## gamma1     NaN
## delta  0.11294
## shape  0.18619
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.49 2.75 3.27
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias           1.5874 0.11282    
## Negative Sign Bias  0.6834 0.49456    
## Positive Sign Bias  2.7563 0.00598 ***
## Joint Effect        8.1100 0.04379  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     9.262       0.9689
## 2    30    18.363       0.9365
## 3    40    26.316       0.9397
## 4    50    29.524       0.9875
## 
## 
## Elapsed time : 1.337209
# GARCH-in-Mean(1,1)
mean_garchm <- list(armaOrder = c(2,2), include.mean = TRUE, archm = TRUE)
spec_garchm <- ugarchspec(
  variance.model = list(model = "sGARCH", garchOrder = c(1,1)),
  mean.model = mean_garchm,
  distribution.model = "std"
)
fit_garchm <- ugarchfit(spec_garchm, data = stock)
show(fit_garchm)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(2,0,2)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error    t value Pr(>|t|)
## mu     -0.222794    0.643395   -0.34628 0.729133
## ar1    -1.592030    0.012759 -124.77310 0.000000
## ar2    -0.705297    0.036872  -19.12840 0.000000
## ma1     1.601938    0.016602   96.49258 0.000000
## ma2     0.732979    0.027833   26.33533 0.000000
## archm   0.164738    0.466371    0.35323 0.723914
## omega   0.036527    0.035451    1.03035 0.302848
## alpha1  0.030523    0.014744    2.07017 0.038437
## beta1   0.951465    0.028460   33.43154 0.000000
## shape   5.143152    0.891572    5.76863 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error   t value Pr(>|t|)
## mu     -0.222794    1.697209  -0.13127  0.89556
## ar1    -1.592030    0.031501 -50.53950  0.00000
## ar2    -0.705297    0.022795 -30.94143  0.00000
## ma1     1.601938    0.017245  92.89417  0.00000
## ma2     0.732979    0.008565  85.58039  0.00000
## archm   0.164738    1.229109   0.13403  0.89338
## omega   0.036527    0.086418   0.42268  0.67253
## alpha1  0.030523    0.027020   1.12962  0.25864
## beta1   0.951465    0.066400  14.32933  0.00000
## shape   5.143152    0.994143   5.17345  0.00000
## 
## LogLikelihood : -1382.597 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       3.4771
## Bayes        3.5356
## Shibata      3.4768
## Hannan-Quinn 3.4996
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                      0.1256  0.7230
## Lag[2*(p+q)+(p+q)-1][11]    3.4331  1.0000
## Lag[4*(p+q)+(p+q)-1][19]    4.5309  0.9978
## d.o.f=4
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      9.232 0.002378
## Lag[2*(p+q)+(p+q)-1][5]    11.124 0.004717
## Lag[4*(p+q)+(p+q)-1][9]    12.050 0.017667
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]     2.435 0.500 2.000  0.1187
## ARCH Lag[5]     3.235 1.440 1.667  0.2575
## ARCH Lag[7]     3.354 2.315 1.543  0.4494
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.8254
## Individual Statistics:              
## mu     0.10933
## ar1    0.09906
## ar2    0.04389
## ma1    0.12212
## ma2    0.06530
## archm  0.08599
## omega  0.26548
## alpha1 0.59439
## beta1  0.48509
## shape  0.55743
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias            2.293 0.02214  **
## Negative Sign Bias   1.368 0.17172    
## Positive Sign Bias   2.457 0.01422  **
## Joint Effect         8.138 0.04324  **
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     22.10       0.2795
## 2    30     20.39       0.8805
## 3    40     42.80       0.3115
## 4    50     47.75       0.5238
## 
## 
## Elapsed time : 0.3812749
# Compare Information Criteria 

infocriteria(fit_garch)
##                      
## Akaike       3.465035
## Bayes        3.517685
## Shibata      3.464786
## Hannan-Quinn 3.485259
infocriteria(fit_gjr)
##                      
## Akaike       3.477226
## Bayes        3.535726
## Shibata      3.476919
## Hannan-Quinn 3.499698
infocriteria(fit_egarch)
##                      
## Akaike       3.476196
## Bayes        3.534697
## Shibata      3.475890
## Hannan-Quinn 3.498668
infocriteria(fit_igarch)
##                      
## Akaike       3.475146
## Bayes        3.521946
## Shibata      3.474949
## Hannan-Quinn 3.493123
infocriteria(fit_aparch)
##                      
## Akaike       3.467837
## Bayes        3.532187
## Shibata      3.467467
## Hannan-Quinn 3.492556
infocriteria(fit_garchm)
##                      
## Akaike       3.477146
## Bayes        3.535646
## Shibata      3.476839
## Hannan-Quinn 3.499618

Best Garch Model - Stock (Reliance)

# GARCH(1,1):      Akaike (AIC): 3.465035, Bayes (BIC): 3.517685  -> Lowest AIC
# GJR-GARCH(1,1):  Akaike (AIC): 3.477226, Bayes (BIC): 3.535726
# EGARCH(1,1):     Akaike (AIC): 3.476196, Bayes (BIC): 3.534697
# IGARCH(1,1):     Akaike (AIC): 3.475146, Bayes (BIC): 3.521946
# APARCH(1,1):     Akaike (AIC): 3.467837, Bayes (BIC): 3.532187
# GARCH-M(1,1):    Akaike (AIC): 3.477146, Bayes (BIC): 3.535646 

cat("Best Model is ---->  **  garch(1,1)** ")
## Best Model is ---->  **  garch(1,1)**
# Significant: (AR1, AR2, MA1, MA2, omega, alpha1, beta1, shape)
 
garch_residuals <- residuals(fit_garch, standardize = TRUE)

#Heteroskedasticity
ArchTest(garch_residuals, lags = 10) 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  garch_residuals
## Chi-squared = 16.549, df = 10, p-value = 0.08495
# p-value = 0.08495 > 0.05 => No presence of ARCH effects

# White noise
Box.test(garch_residuals, lag = 10, type = "Ljung-Box") 
## 
##  Box-Ljung test
## 
## data:  garch_residuals
## X-squared = 11.113, df = 10, p-value = 0.3488
# p-value = 0.3488 => Residuals are white noise

# ACF
asset_name = "(Garch Residuals - Reliance) - "
acf(garch_residuals, main = paste(asset_name, "ACF"))

# no significant autocorrelation 

Garch Model - Index (Nifty 50) With arma(0,0)

# Mean model spec (ARMA(0,0) with mean)
Mean_ <- list(armaOrder = c(0,0), include.mean = TRUE)

# GARCH(1,1)
Spec_garch <- ugarchspec(
  variance.model = list(model = "sGARCH", garchOrder = c(1,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_garch <- ugarchfit(Spec_garch, data = index)
show(Fit_garch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.086971    0.027433   3.1704 0.001523
## omega   0.088488    0.052429   1.6878 0.091456
## alpha1  0.142605    0.056595   2.5197 0.011744
## beta1   0.746737    0.110965   6.7295 0.000000
## shape   6.367347    1.369398   4.6497 0.000003
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.086971    0.034971  2.48693 0.012885
## omega   0.088488    0.127845  0.69215 0.488842
## alpha1  0.142605    0.116226  1.22696 0.219838
## beta1   0.746737    0.273623  2.72907 0.006351
## shape   6.367347    1.506658  4.22614 0.000024
## 
## LogLikelihood : -980.0814 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4596
## Bayes        2.4889
## Shibata      2.4596
## Hannan-Quinn 2.4709
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      2.097  0.1476
## Lag[2*(p+q)+(p+q)-1][2]     2.146  0.2396
## Lag[4*(p+q)+(p+q)-1][5]     3.000  0.4070
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      7.782 0.005278
## Lag[2*(p+q)+(p+q)-1][5]     9.546 0.012027
## Lag[4*(p+q)+(p+q)-1][9]    12.299 0.015499
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.5249 0.500 2.000  0.4688
## ARCH Lag[5]    1.4818 1.440 1.667  0.5971
## ARCH Lag[7]    2.7512 2.315 1.543  0.5617
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.2984
## Individual Statistics:              
## mu     0.05591
## omega  0.84240
## alpha1 1.34712
## beta1  1.46113
## shape  1.15077
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.28 1.47 1.88
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias            1.773 0.07653   *
## Negative Sign Bias   0.623 0.53346    
## Positive Sign Bias   1.139 0.25508    
## Joint Effect         6.241 0.10044    
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     27.54       0.0927
## 2    30     33.87       0.2441
## 3    40     49.79       0.1155
## 4    50     52.75       0.3314
## 
## 
## Elapsed time : 0.07450485
# GJR-GARCH(1,1)
Spec_gjr <- ugarchspec(
  variance.model = list(model = "gjrGARCH", garchOrder = c(1,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_gjr <- ugarchfit(Spec_gjr, data = index)
show(Fit_gjr)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : gjrGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.076813    0.026723  2.87435 0.004049
## omega   0.112895    0.042110  2.68097 0.007341
## alpha1  0.027122    0.038618  0.70232 0.482477
## beta1   0.698295    0.092293  7.56605 0.000000
## gamma1  0.245573    0.086675  2.83325 0.004608
## shape   6.474822    1.374654  4.71014 0.000002
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.076813    0.030867  2.48852 0.012828
## omega   0.112895    0.079765  1.41534 0.156970
## alpha1  0.027122    0.055474  0.48892 0.624897
## beta1   0.698295    0.181859  3.83975 0.000123
## gamma1  0.245573    0.103317  2.37688 0.017460
## shape   6.474822    1.672171  3.87211 0.000108
## 
## LogLikelihood : -973.3209 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4452
## Bayes        2.4803
## Shibata      2.4451
## Hannan-Quinn 2.4587
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.961  0.1614
## Lag[2*(p+q)+(p+q)-1][2]     1.989  0.2646
## Lag[4*(p+q)+(p+q)-1][5]     2.749  0.4547
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      11.08 0.000873
## Lag[2*(p+q)+(p+q)-1][5]     12.73 0.001793
## Lag[4*(p+q)+(p+q)-1][9]     14.62 0.004419
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.2778 0.500 2.000  0.5982
## ARCH Lag[5]    1.2406 1.440 1.667  0.6631
## ARCH Lag[7]    1.5822 2.315 1.543  0.8047
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.553
## Individual Statistics:              
## mu     0.09859
## omega  0.98160
## alpha1 0.81374
## beta1  1.80582
## gamma1 1.43291
## shape  1.41635
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.49 1.68 2.12
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           2.6624 0.0079161 ***
## Negative Sign Bias  0.4702 0.6383198    
## Positive Sign Bias  3.7981 0.0001569 ***
## Joint Effect       14.8883 0.0019147 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     23.14       0.2310
## 2    30     38.06       0.1209
## 3    40     38.80       0.4789
## 4    50     57.74       0.1836
## 
## 
## Elapsed time : 0.1982841
# EGARCH(1,1)
Spec_egarch <- ugarchspec(
  variance.model = list(model = "eGARCH", garchOrder = c(1,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_egarch <- ugarchfit(Spec_egarch, data = index)
show(Fit_egarch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : eGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.075038    0.024583   3.0525 0.002270
## omega  -0.062178    0.027737  -2.2417 0.024980
## alpha1 -0.161581    0.045522  -3.5495 0.000386
## beta1   0.852958    0.058093  14.6826 0.000000
## gamma1  0.207399    0.073081   2.8379 0.004541
## shape   6.559440    1.380537   4.7514 0.000002
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.075038    0.025597   2.9315 0.003374
## omega  -0.062178    0.040929  -1.5191 0.128727
## alpha1 -0.161581    0.050755  -3.1836 0.001455
## beta1   0.852958    0.091207   9.3519 0.000000
## gamma1  0.207399    0.088467   2.3444 0.019059
## shape   6.559440    1.766986   3.7122 0.000205
## 
## LogLikelihood : -970.4638 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4381
## Bayes        2.4732
## Shibata      2.4380
## Hannan-Quinn 2.4516
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.570  0.2102
## Lag[2*(p+q)+(p+q)-1][2]     1.578  0.3434
## Lag[4*(p+q)+(p+q)-1][5]     2.330  0.5428
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      13.77 0.0002070
## Lag[2*(p+q)+(p+q)-1][5]     14.81 0.0004985
## Lag[4*(p+q)+(p+q)-1][9]     16.57 0.0014751
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]   0.01996 0.500 2.000  0.8876
## ARCH Lag[5]   0.81261 1.440 1.667  0.7892
## ARCH Lag[7]   1.04197 2.315 1.543  0.9066
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.9091
## Individual Statistics:              
## mu     0.12360
## omega  1.31789
## alpha1 0.19156
## beta1  0.13578
## gamma1 0.05584
## shape  1.35655
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.49 1.68 2.12
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                     t-value      prob sig
## Sign Bias           2.47835 0.0134053  **
## Negative Sign Bias  0.02552 0.9796455    
## Positive Sign Bias  4.43722 0.0000104 ***
## Joint Effect       19.68964 0.0001968 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     18.30       0.5024
## 2    30     35.52       0.1881
## 3    40     41.90       0.3463
## 4    50     49.50       0.4532
## 
## 
## Elapsed time : 0.07294011
# EGARCH(2,1)
Spec_egarch21 <- ugarchspec(
  variance.model = list(model = "eGARCH", garchOrder = c(2,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_egarch21 <- ugarchfit(Spec_egarch21, data = index)
show(Fit_egarch21)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : eGARCH(2,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.071834    0.025283   2.8412 0.004495
## omega  -0.007678    0.002737  -2.8050 0.005032
## alpha1 -0.138911    0.053207  -2.6108 0.009034
## alpha2  0.087127    0.054871   1.5879 0.112319
## beta1   0.986583    0.004026 245.0453 0.000000
## gamma1  0.330537    0.088245   3.7457 0.000180
## gamma2 -0.276857    0.079324  -3.4902 0.000483
## shape   6.575689    1.144731   5.7443 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.071834    0.030764   2.3350 0.019541
## omega  -0.007678    0.003955  -1.9413 0.052226
## alpha1 -0.138911    0.049178  -2.8246 0.004733
## alpha2  0.087127    0.054666   1.5938 0.110981
## beta1   0.986583    0.007436 132.6786 0.000000
## gamma1  0.330537    0.118069   2.7995 0.005118
## gamma2 -0.276857    0.127832  -2.1658 0.030327
## shape   6.575689    1.694131   3.8815 0.000104
## 
## LogLikelihood : -965.2666 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4301
## Bayes        2.4769
## Shibata      2.4299
## Hannan-Quinn 2.4481
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                     0.5739  0.4487
## Lag[2*(p+q)+(p+q)-1][2]    0.6042  0.6466
## Lag[4*(p+q)+(p+q)-1][5]    1.9230  0.6367
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       18.06 2.145e-05
## Lag[2*(p+q)+(p+q)-1][8]      20.63 7.902e-05
## Lag[4*(p+q)+(p+q)-1][14]     23.63 3.032e-04
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[4]    0.2602 0.500 2.000  0.6100
## ARCH Lag[6]    1.8954 1.461 1.711  0.5143
## ARCH Lag[8]    4.1338 2.368 1.583  0.3560
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  2.3115
## Individual Statistics:             
## mu     0.0669
## omega  0.1776
## alpha1 0.5627
## alpha2 0.4603
## beta1  0.1151
## gamma1 0.4512
## gamma2 0.5303
## shape  1.0480
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.89 2.11 2.59
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias           1.9463 0.05197   *
## Negative Sign Bias  0.7758 0.43807    
## Positive Sign Bias  2.4477 0.01459  **
## Joint Effect        6.6923 0.08238   *
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     25.79      0.13610
## 2    30     35.67      0.18348
## 3    40     42.10      0.33842
## 4    50     62.98      0.08648
## 
## 
## Elapsed time : 0.1181722
# EGARCH(1,2)
Spec_egarch12 <- ugarchspec(
  variance.model = list(model = "eGARCH", garchOrder = c(1,2)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_egarch12 <- ugarchfit(Spec_egarch12, data = index)
show(Fit_egarch12)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : eGARCH(1,2)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.075543    0.026195   2.8839 0.003928
## omega  -0.061918    0.030188  -2.0511 0.040257
## alpha1 -0.168837    0.048819  -3.4584 0.000543
## beta1   0.514169    0.173006   2.9720 0.002959
## beta2   0.342431    0.183330   1.8678 0.061784
## gamma1  0.256316    0.083528   3.0686 0.002150
## shape   6.543926    1.380310   4.7409 0.000002
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.075543    0.029329   2.5757 0.010004
## omega  -0.061918    0.044916  -1.3785 0.168039
## alpha1 -0.168837    0.051337  -3.2888 0.001006
## beta1   0.514169    0.147121   3.4949 0.000474
## beta2   0.342431    0.190151   1.8008 0.071729
## gamma1  0.256316    0.107701   2.3799 0.017317
## shape   6.543926    1.745035   3.7500 0.000177
## 
## LogLikelihood : -969.2126 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4375
## Bayes        2.4784
## Shibata      2.4373
## Hannan-Quinn 2.4532
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.521  0.2174
## Lag[2*(p+q)+(p+q)-1][2]     1.535  0.3530
## Lag[4*(p+q)+(p+q)-1][5]     2.404  0.5264
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       16.07 6.114e-05
## Lag[2*(p+q)+(p+q)-1][8]      18.04 3.752e-04
## Lag[4*(p+q)+(p+q)-1][14]     20.69 1.478e-03
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[4]   0.06981 0.500 2.000  0.7916
## ARCH Lag[6]   1.27562 1.461 1.711  0.6703
## ARCH Lag[8]   3.71719 2.368 1.583  0.4188
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.7881
## Individual Statistics:              
## mu     0.09915
## omega  0.98817
## alpha1 0.34112
## beta1  0.15599
## beta2  0.18276
## gamma1 0.05367
## shape  1.35669
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.69 1.9 2.35
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           2.3619 1.842e-02  **
## Negative Sign Bias  0.3979 6.908e-01    
## Positive Sign Bias  3.9482 8.572e-05 ***
## Joint Effect       15.7471 1.278e-03 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     21.35      0.31794
## 2    30     47.73      0.01569
## 3    40     42.10      0.33842
## 4    50     62.23      0.09707
## 
## 
## Elapsed time : 0.07548499
# IGARCH(1,1)
Spec_igarch <- ugarchspec(
  variance.model = list(model = "iGARCH", garchOrder = c(1,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_igarch <- ugarchfit(Spec_igarch, data = index)
show(Fit_igarch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : iGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.072751    0.026934   2.7011 0.006912
## omega   0.002590    0.003066   0.8448 0.398222
## alpha1  0.035537    0.020640   1.7218 0.085114
## beta1   0.964463          NA       NA       NA
## shape   5.664086    1.133145   4.9986 0.000001
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.072751    0.028201  2.57977 0.009887
## omega   0.002590    0.005517  0.46947 0.638737
## alpha1  0.035537    0.039739  0.89427 0.371176
## beta1   0.964463          NA       NA       NA
## shape   5.664086    1.252941  4.52063 0.000006
## 
## LogLikelihood : -983.4754 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4656
## Bayes        2.4890
## Shibata      2.4656
## Hannan-Quinn 2.4746
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                    0.07165  0.7889
## Lag[2*(p+q)+(p+q)-1][2]   0.18694  0.8623
## Lag[4*(p+q)+(p+q)-1][5]   1.38387  0.7684
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      53.92 2.092e-13
## Lag[2*(p+q)+(p+q)-1][5]     54.20 3.886e-15
## Lag[4*(p+q)+(p+q)-1][9]     55.10 3.508e-14
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]   0.09079 0.500 2.000  0.7632
## ARCH Lag[5]   0.69157 1.440 1.667  0.8260
## ARCH Lag[7]   0.82112 2.315 1.543  0.9408
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  1.5157
## Individual Statistics:              
## mu     0.07006
## omega  0.06002
## alpha1 0.07509
## shape  0.77818
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.07 1.24 1.6
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias            1.923 0.0547969   *
## Negative Sign Bias   2.123 0.0340671  **
## Positive Sign Bias   3.861 0.0001220 ***
## Joint Effect        20.832 0.0001141 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     19.90     0.400686
## 2    30     45.63     0.025534
## 3    40     45.69     0.213953
## 4    50     78.59     0.004629
## 
## 
## Elapsed time : 0.02559805
# APARCH(1,1)
Spec_aparch <- ugarchspec(
  variance.model = list(model = "apARCH", garchOrder = c(1,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_aparch <- ugarchfit(Spec_aparch, data = index)
show(Fit_aparch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : apARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.075715    0.028060   2.6984 0.006968
## omega   0.113991    0.040094   2.8431 0.004468
## alpha1  0.113456    0.034207   3.3168 0.000911
## beta1   0.781897    0.065416  11.9527 0.000000
## gamma1  0.864226    0.239032   3.6155 0.000300
## delta   0.906783    0.264696   3.4257 0.000613
## shape   6.813144    1.470107   4.6345 0.000004
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.075715    0.033530   2.2581 0.023939
## omega   0.113991    0.054491   2.0919 0.036444
## alpha1  0.113456    0.038318   2.9609 0.003067
## beta1   0.781897    0.085786   9.1145 0.000000
## gamma1  0.864226    0.219328   3.9403 0.000081
## delta   0.906783    0.229943   3.9435 0.000080
## shape   6.813144    1.917692   3.5528 0.000381
## 
## LogLikelihood : -969.1142 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4372
## Bayes        2.4782
## Shibata      2.4371
## Hannan-Quinn 2.4530
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.350  0.2453
## Lag[2*(p+q)+(p+q)-1][2]     1.362  0.3945
## Lag[4*(p+q)+(p+q)-1][5]     2.163  0.5805
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      18.67 1.554e-05
## Lag[2*(p+q)+(p+q)-1][5]     19.55 2.577e-05
## Lag[4*(p+q)+(p+q)-1][9]     21.33 9.115e-05
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]  0.006054 0.500 2.000  0.9380
## ARCH Lag[5]  0.905644 1.440 1.667  0.7611
## ARCH Lag[7]  1.145379 2.315 1.543  0.8888
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.472
## Individual Statistics:             
## mu     0.1995
## omega  1.0528
## alpha1 1.4247
## beta1  1.4201
## gamma1 0.1115
## delta  1.1990
## shape  1.5458
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.69 1.9 2.35
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           2.1535 3.158e-02  **
## Negative Sign Bias  0.3459 7.295e-01    
## Positive Sign Bias  4.5462 6.311e-06 ***
## Joint Effect       20.8738 1.118e-04 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     19.10       0.4504
## 2    30     35.44       0.1904
## 3    40     38.90       0.4744
## 4    50     49.25       0.4631
## 
## 
## Elapsed time : 0.2696431
# APARCH(2,1)
Spec_aparch21 <- ugarchspec(
  variance.model = list(model = "apARCH", garchOrder = c(2,1)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_aparch21 <- ugarchfit(Spec_aparch21, data = index)
show(Fit_aparch21)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : apARCH(2,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error   t value Pr(>|t|)
## mu       0.07577    0.027633  2.741980 0.006107
## omega    0.11300    0.039653  2.849740 0.004376
## alpha1   0.11187    0.034184  3.272491 0.001066
## alpha2   0.00000    0.000465  0.000000 1.000000
## beta1    0.78374    0.065136 12.032462 0.000000
## gamma1   0.88236    0.246097  3.585420 0.000337
## gamma2   0.44830   38.034031  0.011787 0.990596
## delta    0.91588    0.259913  3.523797 0.000425
## shape    6.80708    1.465358  4.645339 0.000003
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu       0.07577    0.032578 2.325796 0.020029
## omega    0.11300    0.053933 2.095213 0.036152
## alpha1   0.11187    0.038306 2.920366 0.003496
## alpha2   0.00000    0.000004 0.000036 0.999971
## beta1    0.78374    0.085290 9.189202 0.000000
## gamma1   0.88236    0.226288 3.899271 0.000096
## gamma2   0.44830   44.257006 0.010130 0.991918
## delta    0.91588    0.226492 4.043778 0.000053
## shape    6.80708    1.910103 3.563726 0.000366
## 
## LogLikelihood : -969.0588 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4421
## Bayes        2.4947
## Shibata      2.4418
## Hannan-Quinn 2.4623
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.353  0.2448
## Lag[2*(p+q)+(p+q)-1][2]     1.364  0.3938
## Lag[4*(p+q)+(p+q)-1][5]     2.163  0.5805
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       18.57 0.0000164
## Lag[2*(p+q)+(p+q)-1][8]      20.58 0.0000814
## Lag[4*(p+q)+(p+q)-1][14]     23.24 0.0003758
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[4]    0.1096 0.500 2.000  0.7406
## ARCH Lag[6]    1.2219 1.461 1.711  0.6851
## ARCH Lag[8]    3.8538 2.368 1.583  0.3974
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.7708
## Individual Statistics:             
## mu     0.2034
## omega  1.0357
## alpha1 1.4254
## alpha2 1.2807
## beta1  1.4123
## gamma1 0.0924
## gamma2 0.1291
## delta  1.2204
## shape  1.5466
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.1 2.32 2.82
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           2.1766 2.980e-02  **
## Negative Sign Bias  0.3414 7.329e-01    
## Positive Sign Bias  4.6029 4.848e-06 ***
## Joint Effect       21.3982 8.702e-05 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     18.60       0.4827
## 2    30     37.01       0.1458
## 3    40     37.50       0.5383
## 4    50     50.62       0.4093
## 
## 
## Elapsed time : 0.4533129
# APARCH(1,2)
Spec_aparch12 <- ugarchspec(
  variance.model = list(model = "apARCH", garchOrder = c(1,2)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_aparch12 <- ugarchfit(Spec_aparch12, data = index)
show(Fit_aparch12)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : apARCH(1,2)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.076573    0.026434   2.8968 0.003770
## omega   0.118800    0.042991   2.7633 0.005721
## alpha1  0.127453    0.038485   3.3117 0.000927
## beta1   0.494559    0.260792   1.8964 0.057911
## beta2   0.268398    0.246165   1.0903 0.275574
## gamma1  0.860149    0.251411   3.4213 0.000623
## delta   0.942728    0.259730   3.6296 0.000284
## shape   6.760350    1.442128   4.6878 0.000003
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu      0.076573    0.029746  2.57423 0.010046
## omega   0.118800    0.055064  2.15750 0.030967
## alpha1  0.127453    0.040418  3.15334 0.001614
## beta1   0.494559    0.270765  1.82653 0.067771
## beta2   0.268398    0.274658  0.97721 0.328467
## gamma1  0.860149    0.237725  3.61825 0.000297
## delta   0.942728    0.240239  3.92412 0.000087
## shape   6.760350    1.909525  3.54033 0.000400
## 
## LogLikelihood : -968.5013 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4382
## Bayes        2.4850
## Shibata      2.4380
## Hannan-Quinn 2.4562
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.228  0.2677
## Lag[2*(p+q)+(p+q)-1][2]     1.242  0.4260
## Lag[4*(p+q)+(p+q)-1][5]     2.126  0.5890
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       20.30 6.634e-06
## Lag[2*(p+q)+(p+q)-1][8]      22.03 3.360e-05
## Lag[4*(p+q)+(p+q)-1][14]     24.49 1.886e-04
## d.o.f=3
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[4]   0.05684 0.500 2.000  0.8116
## ARCH Lag[6]   1.17233 1.461 1.711  0.6989
## ARCH Lag[8]   3.52349 2.368 1.583  0.4505
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.6626
## Individual Statistics:              
## mu     0.19046
## omega  0.89200
## alpha1 1.38743
## beta1  1.25473
## beta2  1.27688
## gamma1 0.03721
## delta  1.18499
## shape  1.56919
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.89 2.11 2.59
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                     t-value      prob sig
## Sign Bias           2.18044 2.952e-02  **
## Negative Sign Bias  0.02532 9.798e-01    
## Positive Sign Bias  4.53691 6.588e-06 ***
## Joint Effect       20.80481 1.156e-04 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     22.15       0.2770
## 2    30     38.74       0.1068
## 3    40     44.19       0.2615
## 4    50     46.00       0.5953
## 
## 
## Elapsed time : 0.2729409
# APARCH(2,2)
Spec_aparch22 <- ugarchspec(
  variance.model = list(model = "apARCH", garchOrder = c(2,2)),
  mean.model = Mean_,
  distribution.model = "std"
)
Fit_aparch22 <- ugarchfit(Spec_aparch22, data = index)
show(Fit_aparch22)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : apARCH(2,2)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error   t value Pr(>|t|)
## mu      0.076573    0.026438    2.8963 0.003776
## omega   0.118820    0.048438    2.4530 0.014167
## alpha1  0.127437    0.037281    3.4182 0.000630
## alpha2  0.000000    0.032966    0.0000 1.000000
## beta1   0.494533    0.136703    3.6176 0.000297
## beta2   0.268405    0.149137    1.7997 0.071905
## gamma1  0.860248    0.250584    3.4330 0.000597
## gamma2  0.985258    0.000263 3742.5572 0.000000
## delta   0.942816    0.260923    3.6134 0.000302
## shape   6.760991    1.444956    4.6790 0.000003
## 
## Robust Standard Errors:
##         Estimate  Std. Error   t value Pr(>|t|)
## mu      0.076573    0.029631    2.5842 0.009761
## omega   0.118820    0.070414    1.6874 0.091517
## alpha1  0.127437    0.034923    3.6491 0.000263
## alpha2  0.000000    0.033881    0.0000 1.000000
## beta1   0.494533    0.049752    9.9399 0.000000
## beta2   0.268405    0.148956    1.8019 0.071559
## gamma1  0.860248    0.234568    3.6674 0.000245
## gamma2  0.985258    0.000983 1002.6990 0.000000
## delta   0.942816    0.250230    3.7678 0.000165
## shape   6.760991    1.901407    3.5558 0.000377
## 
## LogLikelihood : -968.5013 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4432
## Bayes        2.5017
## Shibata      2.4429
## Hannan-Quinn 2.4657
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      1.228  0.2678
## Lag[2*(p+q)+(p+q)-1][2]     1.241  0.4261
## Lag[4*(p+q)+(p+q)-1][5]     2.125  0.5891
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic   p-value
## Lag[1]                       20.29 6.639e-06
## Lag[2*(p+q)+(p+q)-1][11]     23.52 7.340e-05
## Lag[4*(p+q)+(p+q)-1][19]     25.53 9.291e-04
## d.o.f=4
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[5]     1.338 0.500 2.000  0.2474
## ARCH Lag[7]     1.466 1.473 1.746  0.6315
## ARCH Lag[9]     4.389 2.402 1.619  0.3424
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  4.4176
## Individual Statistics:              
## mu     0.19042
## omega  0.89206
## alpha1 1.38779
## alpha2 1.24923
## beta1  1.25489
## beta2  1.27703
## gamma1 0.03716
## gamma2 0.74938
## delta  1.18514
## shape  1.56857
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                     t-value      prob sig
## Sign Bias           2.18074 2.949e-02  **
## Negative Sign Bias  0.02541 9.797e-01    
## Positive Sign Bias  4.53743 6.573e-06 ***
## Joint Effect       20.80943 1.153e-04 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     22.15       0.2770
## 2    30     38.74       0.1068
## 3    40     44.19       0.2615
## 4    50     46.00       0.5953
## 
## 
## Elapsed time : 0.496716
# GARCH-in-Mean(1,1)
Mean_garchm <- list(armaOrder = c(0,0), include.mean = TRUE, archm = TRUE)
Spec_garchm <- ugarchspec(
  variance.model = list(model = "sGARCH", garchOrder = c(1,1)),
  mean.model = Mean_garchm,
  distribution.model = "std"
)
Fit_garchm <- ugarchfit(Spec_garchm, data = index)
show(Fit_garchm)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(1,1)
## Mean Model   : ARFIMA(0,0,0)
## Distribution : std 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error  t value Pr(>|t|)
## mu     -0.055388     0.15720 -0.35234 0.724587
## archm   0.174215     0.18886  0.92245 0.356294
## omega   0.077542     0.04842  1.60145 0.109278
## alpha1  0.128671     0.05499  2.33989 0.019289
## beta1   0.773108     0.10609  7.28705 0.000000
## shape   6.412139     1.37116  4.67643 0.000003
## 
## Robust Standard Errors:
##         Estimate  Std. Error  t value Pr(>|t|)
## mu     -0.055388     0.16173 -0.34246 0.732006
## archm   0.174215     0.17805  0.97846 0.327847
## omega   0.077542     0.11136  0.69633 0.486220
## alpha1  0.128671     0.10741  1.19791 0.230953
## beta1   0.773108     0.24485  3.15754 0.001591
## shape   6.412139     1.51680  4.22740 0.000024
## 
## LogLikelihood : -979.6332 
## 
## Information Criteria
## ------------------------------------
##                    
## Akaike       2.4610
## Bayes        2.4961
## Shibata      2.4609
## Hannan-Quinn 2.4745
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic p-value
## Lag[1]                      2.268  0.1321
## Lag[2*(p+q)+(p+q)-1][2]     2.370  0.2081
## Lag[4*(p+q)+(p+q)-1][5]     3.332  0.3497
## d.o.f=0
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                         statistic  p-value
## Lag[1]                      9.707 0.001835
## Lag[2*(p+q)+(p+q)-1][5]    11.437 0.003911
## Lag[4*(p+q)+(p+q)-1][9]    13.942 0.006413
## d.o.f=2
## 
## Weighted ARCH LM Tests
## ------------------------------------
##             Statistic Shape Scale P-Value
## ARCH Lag[3]    0.5092 0.500 2.000  0.4755
## ARCH Lag[5]    1.3678 1.440 1.667  0.6278
## ARCH Lag[7]    2.5910 2.315 1.543  0.5939
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  3.4809
## Individual Statistics:              
## mu     0.07533
## archm  0.07329
## omega  0.75112
## alpha1 1.28240
## beta1  1.35329
## shape  1.20929
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          1.49 1.68 2.12
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value    prob sig
## Sign Bias           1.8363 0.06669   *
## Negative Sign Bias  0.7152 0.47470    
## Positive Sign Bias  1.4797 0.13936    
## Joint Effect        6.7111 0.08170   *
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     34.78      0.01484
## 2    30     43.38      0.04196
## 3    40     48.39      0.14408
## 4    50     58.74      0.16072
## 
## 
## Elapsed time : 0.122926
# Compare Information Criteria 

infocriteria(Fit_garch)
##                      
## Akaike       2.459629
## Bayes        2.488879
## Shibata      2.459552
## Hannan-Quinn 2.470865
infocriteria(Fit_gjr)
##                      
## Akaike       2.445246
## Bayes        2.480346
## Shibata      2.445134
## Hannan-Quinn 2.458729
infocriteria(Fit_egarch)
##                      
## Akaike       2.438112
## Bayes        2.473212
## Shibata      2.438001
## Hannan-Quinn 2.451595
infocriteria(Fit_egarch21)
##                      
## Akaike       2.430129
## Bayes        2.476929
## Shibata      2.429932
## Hannan-Quinn 2.448106
infocriteria(Fit_egarch12)
##                      
## Akaike       2.437485
## Bayes        2.478435
## Shibata      2.437334
## Hannan-Quinn 2.453215
infocriteria(Fit_igarch)
##                      
## Akaike       2.465607
## Bayes        2.489007
## Shibata      2.465557
## Hannan-Quinn 2.474595
infocriteria(Fit_aparch)
##                      
## Akaike       2.437239
## Bayes        2.478189
## Shibata      2.437088
## Hannan-Quinn 2.452969
infocriteria(Fit_aparch21)
##                      
## Akaike       2.442094
## Bayes        2.494745
## Shibata      2.441846
## Hannan-Quinn 2.462319
infocriteria(Fit_aparch12)
##                      
## Akaike       2.438205
## Bayes        2.485006
## Shibata      2.438009
## Hannan-Quinn 2.456183
infocriteria(Fit_aparch22)
##                      
## Akaike       2.443199
## Bayes        2.501699
## Shibata      2.442893
## Hannan-Quinn 2.465671
infocriteria(Fit_garchm)
##                      
## Akaike       2.461007
## Bayes        2.496107
## Shibata      2.460896
## Hannan-Quinn 2.474490

Best Garch Model - Index (Nifty 50) with arma(0,0)

# GARCH(1,1):      Akaike (AIC): 2.459629, Bayes (BIC): 2.488879
# GJR-GARCH(1,1):  Akaike (AIC): 2.445246, Bayes (BIC): 2.480346
# EGARCH(1,1):     Akaike (AIC): 2.438112, Bayes (BIC): 2.473212
# EGARCH(2,1):     Akaike (AIC): 2.438112, Bayes (BIC): 2.473212
# EGARCH(1,2):     Akaike (AIC): 2.438112, Bayes (BIC): 2.473212
# IGARCH(1,1):     Akaike (AIC): 2.465607, Bayes (BIC): 2.489007
# APARCH(1,1):     Akaike (AIC): 2.437239, Bayes (BIC): 2.478189
# APARCH(2,1):     Akaike (AIC): 2.442094, Bayes (BIC): 2.494745
# APARCH(1,2):     Akaike (AIC): 2.438205, Bayes (BIC): 2.485006
# APARCH(2,2):     Akaike (AIC): 2.443199, Bayes (BIC): 2.501699
# GARCH-M(1,1):    Akaike (AIC): 2.461007, Bayes (BIC): 2.496107


cat("Best Model is ---->  **  aparch(1,1)** ")
## Best Model is ---->  **  aparch(1,1)**
# aparch (1,1) has lowest AIC, then egarch(1,1). 
# also, apARCH has all significant coefficients while eGARCH's ω (omega) is not significant.
# Tried Aparch(1,2), Aparch(2,1) - they have same AIC value and same case with egarach(1,2), egarach(2,1)
 
Garch_residuals <- residuals(Fit_aparch, standardize = TRUE)

#Heteroskedasticity
ArchTest(Garch_residuals, lags = 10) 
## 
##  ARCH LM-test; Null hypothesis: no ARCH effects
## 
## data:  Garch_residuals
## Chi-squared = 29.662, df = 10, p-value = 0.0009728
# p-value = 0.0009728 < 0.05 =>  presence of ARCH effects
# aparch(1,1) and egarch(1,1) are the two best model, but both have arch effect, even their high order.

# White noise
Box.test(Garch_residuals, lag = 10, type = "Ljung-Box") 
## 
##  Box-Ljung test
## 
## data:  Garch_residuals
## X-squared = 4.2985, df = 10, p-value = 0.9329
# p-value = 0.9329 => Residuals are white noise

# ACF
asset_name = "(Garch Residuals - Nifty 50) - "
acf(Garch_residuals, main = paste(asset_name, "ACF"))

# no significant autocorrelation 

conditional variance - Stock (Reliance) with best Garch(1,1) - arma(2,2)

cond_var_garch      <- sigma(fit_garch)^2
cond_var_gjr        <- sigma(fit_gjr)^2
cond_var_egarch     <- sigma(fit_egarch)^2
cond_var_igarch     <- sigma(fit_igarch)^2
cond_var_aparch     <- sigma(fit_aparch)^2
cond_var_garchm     <- sigma(fit_garchm)^2

# Best Model
plot(cond_var_garch, type = "l", col = "blue", 
     main = "Conditional Variance - (Garch(1,1)+ arma(2,2))",
     xlab = "Time", ylab = "Conditional Variance")

plot(cond_var_garch, type = "l", col = "blue", 
     main = "Comparison of Conditional Variances ",
     xlab = "Time", ylab = "Conditional Variance",
     ylim = range(c(cond_var_garch, cond_var_gjr, cond_var_egarch, 
                    cond_var_igarch, cond_var_aparch, cond_var_garchm), na.rm = TRUE))

lines(cond_var_gjr, col = "red")

lines(cond_var_egarch, col = "green")

lines(cond_var_igarch, col = "purple")

lines(cond_var_aparch, col = "orange")

lines(cond_var_garchm, col = "brown")
legend("topright", 
       legend = c("GARCH", "GJR-GARCH", "EGARCH", "IGARCH", "APARCH", "GARCH-M"),
       col = c("blue", "red", "green", "purple", "orange", "brown"),
       lty = 1, cex = 0.8)

conditional mean - Stock (Reliance) with best Garch(1,1) - arma(2,2)

cond_mean_garch <- fitted(fit_garch)

# Plot conditional mean
plot(cond_mean_garch, type = "l", col = "blue", lwd = 2,
     main = "Conditional Mean - Garch(1,1) +arma(0,0)",
     ylab = "Conditional Mean", xlab = "Time")

conditional variance - Index (Nifty 50) with aparch(1,1) + arma(0,0)

Cond_var_garch      <- sigma(Fit_garch)^2
Cond_var_gjr        <- sigma(Fit_gjr)^2
Cond_var_egarch     <- sigma(Fit_egarch)^2
Cond_var_igarch     <- sigma(Fit_igarch)^2
Cond_var_aparch     <- sigma(Fit_aparch)^2
Cond_var_garchm     <- sigma(Fit_garchm)^2

# Best Model
plot(Cond_var_garch, type = "l", col = "blue", 
     main = "Conditional Variance - aparch(1,1) + arma(0,0))",
     xlab = "Time", ylab = "Conditional Variance")

plot(Cond_var_garch, type = "l", col = "blue", 
     main = "Comparison of Conditional Variances ",
     xlab = "Time", ylab = "Conditional Variance",
     ylim = range(c(Cond_var_garch, Cond_var_gjr, Cond_var_egarch, 
                    Cond_var_igarch, Cond_var_aparch, Cond_var_garchm), na.rm = TRUE))

lines(Cond_var_gjr, col = "red")

lines(Cond_var_egarch, col = "green")

lines(Cond_var_igarch, col = "purple")

lines(Cond_var_aparch, col = "orange")

lines(Cond_var_garchm, col = "brown")
legend("topright", 
       legend = c("GARCH", "GJR-GARCH", "EGARCH", "IGARCH", "APARCH", "GARCH-M"),
       col = c("blue", "red", "green", "purple", "orange", "brown"),
       lty = 1, cex = 0.8)

conditional mean - Index (Nifty 50) with aparch(1,1) + arma(0,0)

Cond_mean_garch <- fitted(Fit_aparch)

# Plot conditional mean
plot(Cond_mean_garch, type = "l", col = "blue", lwd = 2,
     main = "Conditional Mean - aparch(1,1) + arma(0,0)",
     ylab = "Conditional Mean", xlab = "Time")

Forecast for Stock Reliance

# next 5 days Forecast
forecast <- ugarchforecast(fit_garch, n.ahead = 5)
sigma_forecast <- sigma(forecast)
show(sigma_forecast)
##     2024-12-31
## T+1   1.292178
## T+2   1.293527
## T+3   1.294858
## T+4   1.296172
## T+5   1.297468
# Volatility is increasing slightly daily, which means model expects increase in risk (slightly) over next 5 days, won't #affect stability of market that much 

Forecast for Index Nifty 50

# next 5 days Forecast
Forecast <- ugarchforecast(Fit_aparch, n.ahead = 5)
Sigma_forecast <- sigma(Forecast)
show(Sigma_forecast)
##     2024-12-31
## T+1  0.8566277
## T+2  0.8523561
## T+3  0.8486657
## T+4  0.8454772
## T+5  0.8427222
# Volatility is slowly decreasing slightly, model expects market to be less risky over the next 5 days, suggesting a calm # # period ahead.